package com.cskaoyan.com.linked;

public class DemoLinked1 {
    public static void main(String[] args) {

        // A --> B ---> C --> D
        Node a = new Node("A");
        Node b = new Node("B");
        Node c = new Node("C");
        Node d = new Node("D");

        a.next = b;
        b.next = c;
        c.next = d;

        // A --> B ---> C --> D
        // System.out.println(a.next.next.value);

        // 构建一个单向循环链表  A --> B ---> C --> D --> A --> B --> ....
        d.next = a;

        System.out.println(a);

    }
}

// 结点类型
class Node{
    String value; // 值域
    Node next; // 指针域

    public Node(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "Node{" +
                "value='" + value + '\'' +
                ", next=" + next +
                '}';
    }
}